<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="/favicon.ico" >
<LINK rel="Shortcut Icon" href="/favicon.ico" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/iconfont.css" />
<link rel="stylesheet" type="text/css" href="/static/admin/css/style.css" />
<title>管理员列表</title>
</head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span> 管理员管理 <span class="c-gray en">&gt;</span> 管理员列表
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a>
</nav>
<div class="page-container">
    <form method="get">
    <div class="text-c">
        <input type="text" class="input-text" style="width:250px" placeholder="输入管理员名称" id="" name="searchName" value="<?php echo isset($display['searchName']) ? $display['searchName'] : ''?>">
        <button type="submit" class="btn btn-success" id="" name=""><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
    </div>
    <div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"> <a href="javascript:;" onclick="show('添加管理员','{:url('admin/adminadd')}','800','500')" class="btn btn-primary radius"><i class="Hui-iconfont">&#xe600;</i> 添加管理员</a></span>  </div>
    <table class="table table-border table-bordered table-bg">
        <thead>
        <tr>
            <th scope="col" colspan="9">管理员列表</th>
        </tr>
        <tr class="text-c">
            <th width="25"><input type="checkbox" name="" value=""></th>
            <th width="40">ID</th>
            <th width="150">用户名</th>
            <th>角色名称</th>
            <th width="130">注册时间</th>
            <th width="100">状态</th>
            <th width="100">操作</th>
        </tr>
        </thead>
        <tbody>
        <?php foreach($result as $v){?>
        <tr class="text-c">
            <td><input type="checkbox" value="1" name=""></td>
            <td><?php echo $v['id']?></td>
            <td><?php echo $v['username']?></td>
            <td><?php echo $v['title']?></td>
            <td><?php echo date('Y-m-d H:i:s',$v['create_time'])?></td>
            <td class="td-status">
                <span class="label <?php echo $v['status'] == 1 ? 'label-success' : ($v['status'] == 2 ? 'label-secondary ' : 'label-defaunt');?> radius">
                    <?php echo $v['status'] == 1 ? '已启用' : ($v['status'] == 2 ? '未激活' : '已禁用');?></span></td>
            <td class="td-manage">
                <?php if($v['status'] == 1){?>
                <a href="javascript:;" title="禁用" onclick="stop(this,'<?php echo $v['id']?>')" style="text-decoration:none"><i class="Hui-iconfont">&#xe60e;</i></a>
                <?php } if($v['status'] == 0) {?>
                <a href="javascript:;" title="启用" onclick="start(this,'<?php echo $v['id']?>')" style="text-decoration:none"><i class="Hui-iconfont">&#xe605;</i></a>
                <?php } if($v['status'] == 2){?>
                <a href="javascript:;" title="激活" onclick="start(this,'<?php echo $v['id']?>')" style="text-decoration:none"><i class="Hui-iconfont">&#xe615;</i></a>
                <?php }?>
                <a style="text-decoration:none" class="ml-5" onClick="show('修改密码','<?php echo url('admin/adminChangePassword',['id'=>$v['id']])?>','500','300')" href="javascript:;" title="修改密码"><i class="Hui-iconfont">&#xe63f;</i></a>
                <a title="编辑" href="javascript:;" onclick="show('管理员编辑','<?php echo url('admin/adminSave',['id'=>$v['id']])?>','800','500')" class="ml-5" style="text-decoration:none"><i class="Hui-iconfont">&#xe6df;</i></a>
            </td>
        </tr>
        <?php }?>
        </tbody>
    </table>
    </form>
</div>

<script type="text/javascript" src="/static/admin/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/admin/js/layer.js"></script>
<script type="text/javascript" src="/static/admin/js/H-ui.min.js"></script>
<script type="text/javascript" src="/static/admin/js/H-ui.admin.js"></script>
<script type="text/javascript" src="/static/admin/js/jquery.validate.js"></script>
<script type="text/javascript" src="/static/admin/js/validate-methods.js"></script>
<script type="text/javascript" src="/static/admin/js/messages_zh.js"></script>
<script type="text/javascript">
/*
 参数解释：
 title	标题
 url		请求的url
 id		需要操作的数据id
 w		弹出层宽度（缺省调默认值）
 h		弹出层高度（缺省调默认值）
 */
/*管理员-增加,编辑*/
function show(title,url,w,h){
    layer_show(title,url,w,h);
}

/*停用*/
function stop(obj,id){
    layer.confirm('确认要禁用吗？',function(index){
        $.ajax({
            type:'post',
            url:"<?php echo url('business/stop')?>",
            data:{"id":id},
            success:function(data){
                if(typeof data === 'string'){
                    data = jQuery.parseJSON(data);
                }
                if(data.code == 0){
                    $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="start(this,'+id+')" href="javascript:;" title="启用"><i class="Hui-iconfont">&#xe605;</i></a>');
                    $(obj).parents("tr").find(".td-status").html('<span class="label label-defaunt radius">已禁用</span>');
                    $(obj).remove();
                    layer.msg('已禁用！',{icon: 7,time:1000});
                }else{
                    layer.msg(data.msg,{icon:5,time:1000});
                }
            }
        });
    });
}

/*启用*/
function start(obj,id){
    layer.confirm('确认要启用吗？',function(index){
        $.ajax({
            type:'post',
            url:"<?php echo url('business/start')?>",
            data:{"id":id},
            success:function(data){
                if(typeof data === 'string'){
                    data = jQuery.parseJSON(data);
                }
                if(data.code == 0){
                    $(obj).parents("tr").find(".td-manage").prepend('<a style="text-decoration:none" onClick="stop(this,'+id+')" href="javascript:;" title="禁用"><i class="Hui-iconfont">&#xe60e;</i></a>');
                    $(obj).parents("tr").find(".td-status").html('<span class="label label-success radius">已启用</span>');
                    $(obj).remove();
                    layer.msg('已启用！',{icon: 1,time:1000});
                }else{
                    layer.msg(data.msg,{icon:5,time:1000});
                }
            }
        });
    });
}
</script>
</body>
</html>